/*#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <iostream>
using namespace std;

int main(int argc, char **argv)
{
        printf("Welcome to Vector World!\n");
        
  vector<float> v;

v.assign( 8, 16.3 );
v[2] = 16.4; v[3] = 20.6;
v.push_back(17.8);
v.push_back(-7.3);

for( int i = 0; i < v.size(); i++ )
 {
cout << v[i] << " ";
}
cout << endl;
cout << v.front() << " " << v.at(2) << " " << v.back() << endl;

vector<float>::iterator iter;
for( iter = v.begin(); iter != v.end(); iter++ ) {
cout << *iter << endl;
}
  
  
}*/

#include <iostream>
#include <map>
#include <utility> // make_pair
using namespace std;
 
int main(int argc, char **argv)
{
    typedef std::map<char, int> MapType;
    MapType my_map;
 
    // insert elements using insert function
    my_map.insert(std::pair<char, int>('a', 1));
    my_map.insert(std::pair<char, int>('b', 2));
    my_map.insert(std::pair<char, int>('c', 3));
    my_map.insert(MapType::value_type('d', 4)); // all standard containers provide this typedef
    my_map.insert(std::make_pair('e', 5));      // can also use the utility function make_pair
 
 
    //map keys are sorted automatically from lower to higher. 
    //So, my_map.begin() points to the lowest key value not the key which was inserted first.
    MapType::iterator iter = my_map.begin();
 
    // erase the first element using the erase function
    my_map.erase(iter);
 
    // output the size of the map
    std::cout << "Size of my_map: " << my_map.size() << '\n';
 
    std::cout << "Enter a key to search for: ";
    char c;
    std::cin >> c;
 
    // find will return an iterator to the matching element if it is found
    // or to the end of the map if the key is not found
    iter = my_map.find(c);
    if (iter != my_map.end() ) 
        std::cout << "Value is: " << iter->second << '\n';
    else
        std::cout << "Key is not in my_map" << '\n';
 
    // clear the entries in the map
    my_map.clear();
}

